package org.loong.crypto.service.core.provider.impl;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

import org.loong.crypto.core.algorithm.CipherAlgorithm;
import org.loong.crypto.core.algorithm.EncryptionMethod;

/**
 * The base abstract class for ECIES encrypter and decrypter.
 * 
 * <p>Supports the following algorithms:
 *
 * <ul>
 *     <li>{@link org.loong.crypto.core.algorithm.CipherAlgorithm#ECIES}
 * </ul>
 * 
 * <p>
 * Supports the following encrypt methods:
 *
 * <ul>
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA1}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA256}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA384}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA512}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_DESEDE_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA1_DESEDE_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA256_DESEDE_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA384_DESEDE_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA512_DESEDE_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_AES_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA1_AES_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA256_AES_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA384_AES_CBC}
 *     <li>{@link org.loong.crypto.core.algorithm.EncryptionMethod#ECIES_SHA512_AES_CBC}
 * </ul>
 */
public abstract class ECIESCipherProvider extends BaseCipherProvider {

    /**
     * The supported encryption algorithms by the ECIES cipher provider class.
     */
    public static final Set<CipherAlgorithm> SUPPORTED_ALGORITHMS;

    /**
     * The supported encryption methods by the ECIES cipher provider class.
     */
    public static final Set<EncryptionMethod> SUPPORTED_ENCRYPTION_METHODS;
    
    static {
        Set<CipherAlgorithm> algs = new LinkedHashSet<>();
        algs.add(CipherAlgorithm.ECIES);
        SUPPORTED_ALGORITHMS = Collections.unmodifiableSet(algs);
        
        Set<EncryptionMethod> encs = new LinkedHashSet<>();
        encs.add(EncryptionMethod.ECIES);
        encs.add(EncryptionMethod.ECIES_SHA1);
        encs.add(EncryptionMethod.ECIES_SHA256);
        encs.add(EncryptionMethod.ECIES_SHA384);
        encs.add(EncryptionMethod.ECIES_SHA512);
        encs.add(EncryptionMethod.ECIES_DESEDE_CBC);
        encs.add(EncryptionMethod.ECIES_SHA1_DESEDE_CBC);
        encs.add(EncryptionMethod.ECIES_SHA256_DESEDE_CBC);
        encs.add(EncryptionMethod.ECIES_SHA384_DESEDE_CBC);
        encs.add(EncryptionMethod.ECIES_SHA512_DESEDE_CBC);
        encs.add(EncryptionMethod.ECIES_AES_CBC);
        encs.add(EncryptionMethod.ECIES_SHA1_AES_CBC);
        encs.add(EncryptionMethod.ECIES_SHA256_AES_CBC);
        encs.add(EncryptionMethod.ECIES_SHA384_AES_CBC);
        encs.add(EncryptionMethod.ECIES_SHA512_AES_CBC);
        SUPPORTED_ENCRYPTION_METHODS = Collections.unmodifiableSet(encs);
    }

    /**
     * Creates a new ECIES provider.
     */
    protected ECIESCipherProvider() {
        super(SUPPORTED_ALGORITHMS, SUPPORTED_ENCRYPTION_METHODS);
    }
}
